package itsm.isperp.module.repository.solr;

import itsm.isperp.module.entity.app.AppUser;

import org.springframework.data.domain.Page;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.solr.core.SolrOperations;
import org.springframework.data.solr.core.query.Criteria;
import org.springframework.data.solr.core.query.Query;
import org.springframework.data.solr.core.query.SimpleQuery;

/**
 * 人员检索
 * 
 * @author lizx
 * @date 2013-4-11
 */
@NoRepositoryBean
@DbConfigEntity(name = "appUser")
public class SolrAppUserRepository extends BaseSolrRepository<AppUser> {

	/**
	 * 使用全文检索查询用户姓名
	 * 
	 * @param fullname
	 *            姓名
	 * @return 分页人员列表
	 */
	public Page<AppUser> searchByFullname(String fullname) {
		Query query = new SimpleQuery(
				new Criteria("fullname").contains(fullname));
		SolrOperations so = getSolrOperations();
		return so.queryForPage(query, AppUser.class);
	}

}
